/**
 * Created by Sky on 2016/7/19.
 */
module.exports = function ($location,$rootScope,$scope,$state,$stateParams,AUTH_EVENTS, contactInfoService,Session,publicService) {
    var browser=publicService.is_weixn();
    if(browser==false){
        window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid=1&redirect_uri=1&response_type=code&scope=snsapi_base&state=1&connect_redirect=1#wechat_redirect";

    }
    var pid= $stateParams.pid;
    var token=$stateParams.token;
    localStorage.token=token;
    var displayname='';
    Session.create(token,displayname);
    publicService.openLoading();
    $scope.closeErrInfo=function(){
        $rootScope.fadeShow1=false;
        $rootScope.loadingErrShow=false;
        $('html,body').removeClass('ovfHiden');
    };

  /*  //获取联系人信息
    contactInfoService.getPersonData(token).then(function (data) {
        publicService.closeLoading();
        $scope.contactPerson=data.contactPerson;
        $scope.contactTel=data.contactTel;
        $scope.contactEmail=data.contactEmail;
        $scope.companyName=data.companyName;
    }, function () {
        publicService.closeLoading();
        $rootScope.fadeShow1=true;
        $rootScope.loadingShow=false;
        $rootScope.loadingErrShow=true;
        $scope.errIcon="images/errIcon.png";
    });*/
    //获取登陆用户信息
    contactInfoService.getUserData(token).then(function (data) {
        publicService.closeLoading();
        $scope.users = data;
        var displayname=data.displayname;
        $scope.displayName=data.displayname;
        Session.create(token,data.displayname);
    }, function () {
        publicService.closeLoading();
        $rootScope.fadeShow1=true;
        $rootScope.loadingErrShow=true;
        $scope.errIcon="images/errIcon.png";
        console.log('获取列表异常！');
    });
}
